<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/21/0021
 * Time: 17:14
 */

namespace App\Http\Controllers\Api\Admin;


use App\Http\Controllers\Api\Controller;
use App\Transformers\UsersTransformer;
use App\User;
use Illuminate\Http\Request;

class MembersController extends Controller
{
    public function index(User $user,Request $request){

        $query = $user->query();
        $params = $request->all();
        if (!empty($params['p_money'])){
            $query->orderBy('p_money',$params['p_money']);
        }

        if (!empty( $params['z_money'])){
            $query->orderBy('z_money',$params['z_money']);
        }

        if (!empty($params['g_money'])){
            $query->orderBy('g_money',$params['g_money']);
        }

        $users = $query->paginate(20);

        return $this->response->paginator($users,new UsersTransformer(true));
    }

}